{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "a = [1,2,3,4]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "a.insert(2, 5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[1, 2, 5, 3, 4]"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on class map in module builtins:\n",
      "\n",
      "class map(object)\n",
      " |  map(func, *iterables) --> map object\n",
      " |  \n",
      " |  Make an iterator that computes the function using arguments from\n",
      " |  each of the iterables.  Stops when the shortest iterable is exhausted.\n",
      " |  \n",
      " |  Methods defined here:\n",
      " |  \n",
      " |  __getattribute__(self, name, /)\n",
      " |      Return getattr(self, name).\n",
      " |  \n",
      " |  __iter__(self, /)\n",
      " |      Implement iter(self).\n",
      " |  \n",
      " |  __next__(self, /)\n",
      " |      Implement next(self).\n",
      " |  \n",
      " |  __reduce__(...)\n",
      " |      Return state information for pickling.\n",
      " |  \n",
      " |  ----------------------------------------------------------------------\n",
      " |  Static methods defined here:\n",
      " |  \n",
      " |  __new__(*args, **kwargs) from builtins.type\n",
      " |      Create and return a new object.  See help(type) for accurate signature.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "set().remove()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "https://leetcode.com/problems/sum-of-even-numbers-after-queries\n",
    "\n",
    "\n",
    "Time Limit Exceeded\n",
    "\n",
    "\n",
    "```python\n",
    "class Solution:\n",
    "    def sumEvenAfterQueries(self, A: List[int], queries: List[List[int]]) -> List[int]:\n",
    "        r = []\n",
    "        evenIndex = set()\n",
    "        \n",
    "        for i, val in enumerate(A):\n",
    "            if val % 2 == 0:\n",
    "                evenIndex.add(i)\n",
    "        \n",
    "        for item in queries:\n",
    "            val = item[0]\n",
    "            key = item[1]\n",
    "            \n",
    "            newValue = A[key] + val\n",
    "            if newValue % 2 == 0:\n",
    "                #print(\"adding\", key)\n",
    "                evenIndex.add(key)\n",
    "            else:\n",
    "                #print(\"removing\", key)\n",
    "                if key in evenIndex:\n",
    "                    evenIndex.remove(key)\n",
    "            A[key] = newValue\n",
    "                \n",
    "            r.append(sum(list(map(lambda x: A[x], evenIndex))))\n",
    "            \n",
    "        return r\n",
    "```"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
